package com.eightbears.beboy.adapter;

import android.text.TextUtils;
import android.view.View;

import com.amap.api.services.core.PoiItem;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.eightbears.beboy.R;

/**
 *
 */

public class LocationAddressAdapter extends BaseQuickAdapter<PoiItem, BaseViewHolder> {

    private PoiItem selItem;

    public LocationAddressAdapter() {
        super(R.layout.item_location_address, null);
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, PoiItem listBean) {
        if (TextUtils.isEmpty(listBean.getSnippet())) {
            baseViewHolder.getView(R.id.rl_root).setVisibility(View.GONE);
        }
        baseViewHolder.setVisible(R.id.iv_sel, false);

        if(null != selItem && selItem.getPoiId().equals(listBean.getPoiId())) {
            baseViewHolder.setVisible(R.id.iv_sel, true);
        }
        baseViewHolder.setText(R.id.tv_location_title, listBean.getTitle())
                .setText(R.id.tv_location_snipet, listBean.getCityName() + " " + listBean.getAdName() + " " + listBean.getSnippet())
                .addOnClickListener(R.id.ll_item_middle);
    }


    public void selItem(PoiItem selPoiItem){
        selItem = selPoiItem;
        notifyDataSetChanged();
    }
}
